package org.drushpal.view.forms
{
	import mx.events.CloseEvent;
	import mx.managers.PopUpManager;
	
	import org.drushpal.model.ConnectionModel;
	import org.robotlegs.mvcs.Mediator;
	
	public class ConnectionFormMediator extends Mediator
	{
		
		[Inject]public var connectionForm:ConnectionForm;
		[Inject]public var connectionModel:ConnectionModel;
		public function ConnectionFormMediator()
		{
		}
		override public function onRegister():void{
			eventMap.mapListener(connectionForm,ConnectionEvent.SAVE_CONNECTION,onSaveConnection);
			eventMap.mapListener(connectionForm,CloseEvent.CLOSE,onClose);
		}
		private function onSaveConnection(event:ConnectionEvent):void{
			connectionModel.saveConnection(event.connection);
		}
		private function onClose(event:CloseEvent):void{
			mediatorMap.removeMediatorByView(connectionForm);
			PopUpManager.removePopUp(connectionForm);
		}
	}
}